#include<iostream>
#include<string>
using namespace std;
class Solution {
public:
    int firstUniqChar(string s) {
        int cur = -1;
        int arr[26] = { 0 };
        for (int i = 0; i < s.size(); i++) {
            arr[s[i] - 'a']++;
        }
        for (int i = 0; i < s.size(); i++) {
            if (arr[s[i] - 'a'] == 1) {
                cur = i;
                break;
            }
        }
        return cur;
    }
};